23 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
24 #define For(i, a, b) for (int i=(a); i<(b); ++i)
25 #define D(x) cout << #x " is " << x << endl
27 string A
[3], B
[3], C
[3];
29 int value(const string
&s
) {
30 return s
== "up" ? +1 : s
== "down" ? -1 : 0;
33 bool works(char letter
, int v
) {
34 for (int i
= 0; i
< 3; ++i
) {
36 for (int k
= 0; k
< A
[i
].size(); ++k
) sa
+= v
* (A
[i
][k
] == letter
);
37 for (int k
= 0; k
< B
[i
].size(); ++k
) sb
+= v
* (B
[i
][k
] == letter
);
38 if (sa
- sb
!= value(C
[i
])) return false;
44 int cases
; cin
>> cases
;
46 for (int i
= 0; i
< 3; ++i
) cin
>> A
[i
] >> B
[i
] >> C
[i
];
47 for (char c
= 'A'; c
<= 'Z'; ++c
) {
49 printf("%c is the counterfeit coin and it is heavy.\n", c
);
53 printf("%c is the counterfeit coin and it is light.\n", c
);